﻿using System;
using System.Collections.Generic;
using System.Text;
using SharpSvn;

namespace TSVNAddin.SVN
{
	public class SVNClientAdapter
	{
		public virtual SVNInfoArgs GetRepositoryInfo(string fileName)
		{
			using (SvnClient client = new SvnClient())
			{
				SvnInfoEventArgs info;
				SvnTarget svnTarget = SvnTarget.FromString(fileName);

				try
				{
					client.GetInfo(svnTarget, out info);
				}
				catch (SvnInvalidNodeKindException)
				{
					return null;
				}

				return new SVNInfoArgs()
				{
					RootAddress = info.RepositoryRoot,
					FileAddress = info.Uri
				};
			}
		}
	}
}
